import { http } from '@/utils/http';
import type { School, CityCountry } from './index.d';

export { School, CityCountry };

/** 获取地区下所有学校 */
export const getSchoolList = (id?: number) => {
	return http<School.Data[]>({
		url: `/api/school`,
		method: 'POST',
		data: id ? { county_id: id } : {},
	});
};

/** 获取学校下班级 */
export const getClassList = (id?: number) => {
	return http<School.ClassData[]>({
		url: `/api/school_class`,
		method: 'POST',
		data: id ? { school_id: id } : {},
	});
};

/** 获取城市接口 */
export const getCityCountryList = (id?: number) => {
	return http<CityCountry.CityData[]>({
		url: `/api/region`,
		method: 'POST',
		data: id ? { id } : {},
	});
};

/** 获取年级接口 */
export const getGradeList = (school_id: number) => {
	return http<School.GradeData[]>({
		url: `/api/school_grade`,
		method: 'GET',
		query: { school_id },
	});
};

/** 获取协议接口 */
export const getProtocol = (type: string) => {
	return http<string>({
		url: `/api/agreement/get_agreement`,
		method: 'POST',
		data: { type },
	});
};
